import { defineStore } from 'pinia'
import { ref } from 'vue'

// 定义store
export const useStudyInfoStore = defineStore(
	'studyInfo',
	() => {
		const studyMode = ref(0)
		const studyWordsList = ref([])
		
		const setStudyMode = (val) => {
			studyMode.value = val
		}
			
		const setStudyWordsList = (val) => {
			studyWordsList.value = val
		}
		
		const clearStudyWordsList = () => {
			studyWordsList.value = []
		}
		
		
		return {
			studyMode,
			studyWordsList,
			setStudyMode,
			setStudyWordsList,
			clearStudyWordsList
		}
	},
	
	//持久化
	{
		//配置持久化
		persist: {
			storage: {
				setItem(key, value) {
					uni.setStorageSync(key, value)
				},
				getItem(key) {
					return uni.getStorageSync(key)
				},
			}
		}
	}
)